# Copyright (c) 2020 Mobvoi Inc. (authors: Binbin Zhang, Xiaoyu Chen, Di Wu)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function

import argparse
import copy
import logging
import os
import sys
from tqdm import tqdm

import torch
import yaml
from torch.utils.data import DataLoader

from wenet.dataset.dataset import Dataset
from wenet.utils.checkpoint import load_checkpoint, load_checkpoint_for_test
from wenet.utils.file_utils import read_symbol_table, read_non_lang_symbols
from wenet.utils.config import override_config
from wenet.utils.init_model import init_model
from wenet.lora.set_lora import set_lora

with open(args.config, 'r') as fin:
    configs = yaml.load(fin, Loader=yaml.FullLoader)
# Init asr model from configs
model = init_model(configs)
logging.info(args.checkpoint)
infos = load_checkpoint_for_test(model, args.llm_path)
device = torch.device('cuda')
model = model.to(device)
cnt = 0
model.eval()
hyps = model.inference(
                text="你好我的耿雪龙",
                text_len=[10],
                prompt_text=None,
                prompt_text_len=None,
                embedding=None)